package vcp.client.GUI.mvc.view;

import java.awt.BorderLayout;
import java.awt.Dimension;

import vcp.client.GUI.mvc.view.addons.LeftNavigation;
/**
 * <p> user interface sub root view class </p>
 * @author VCP team
 *
 */
public class UISubRootView extends UIAbstractView
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	protected LeftNavigation leftNavigationView;
	/**
	 * method removes left navigation view
	 */
	public void removeLeftNavigation()
	{
		if(this.leftNavigationView != null)
		{
			this.remove(this.leftNavigationView);
		}
	}
	/**
	 * method sets left navigation view
	 * @param leftNavigationView
	 */
	public void setLeftNavigationView ( LeftNavigation leftNavigationView )
	{
		if ( this.leftNavigationView != null )
		{
			this.remove(leftNavigationView);
			this.leftNavigationView = null;
		}

		this.leftNavigationView = leftNavigationView;
		this.leftNavigationView.setControllerDelegate(this.controllerDelegate);
		this.add(this.leftNavigationView, BorderLayout.WEST);
		this.reDrawScreen();
	}
	/**
	 * constructor
	 */
	public UISubRootView ()
	{
		super();
	}


	/****************************************************************************************************************************
	 *** Public methods ***
	 ****************************************************************************************************************************/
	/**
	 * method adds view on screen
	 * @param comp
	 * @param constraints
	 */
	public void addView ( UIAbstractView comp, Object constraints )
	{
		comp.setPreferredSize(new Dimension(this.getWidth(), this.getHeight()));
		this.add(comp, constraints);

		this.reDrawScreen();
	}
	/**
	 * method removes view from screen
	 * @param view
	 */
	public void removeView ( UIAbstractView view )
	{
		this.remove(view);
	}


	/****************************************************************************************************************************
	 *** Protected methods ***
	 ****************************************************************************************************************************/
	/**
	 * <p>
	 * This method will be called <b><u>only</u></b> after replacement of inner
	 * views is finished
	 * </p>
	 * To allow correct redrawing on screen
	 */
	protected void reDrawScreen ()
	{
		this.validate();
		this.repaint();
	}


	/****************************************************************************************************************************
	 *** UIAbstractView methods ***
	 ****************************************************************************************************************************/
	@Override
	protected void setupLayout()
	{
		this.setLayout(new BorderLayout(0, 0));
	}

	/*
	 * @see vcp.client.mvc.view.UIAbstractView#setupListeners()
	 */
	@Override
	protected void setupListeners ()
	{
	}
}
